package com.example.mobileeducationstudentv;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.widget.TextView;

public class Study extends Activity {
	private static final String TAG = "StudyActivity";

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.study);

		File sdCard = Environment.getExternalStorageDirectory(); // get SD card
																	// directory
		File file = new File(sdCard, "datamininglecture.txt"); // filename and
																// location
		StringBuilder text = new StringBuilder(); // to hold the contents of the
													// text file

		// try to read the contents of the file
		try {
			BufferedReader br = new BufferedReader(new FileReader(file));
			String line;

			// while there are still lines in the buffered reader, append it to
			// the stringbuilder followed by a line break
			while ((line = br.readLine()) != null) {
				text.append(line);
				text.append('\n');
			}
			Log.i(TAG, "File read successfully!");
		} catch (IOException e) {
			e.printStackTrace();
			Log.e(TAG, "Failure to read file");
		}

		// /Find the text view by its id
		TextView tv = (TextView) findViewById(R.id.text_view);

		// Display the text in the stringbuilder on the text view
		tv.setText(text);
	}
}
